package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.dao.GeneDAO;
import lab.gene.dao.GeneAmplificationDAO;
import lab.gene.pojo.Gene;
import lab.gene.pojo.GeneAmplification;
import lab.gene.service.GeneAMPService;
import lab.user.dao.UserDAO;
import lab.user.pojo.User;

public class GeneAMPServiceImpl implements GeneAMPService {

	@Override
	public void addGeneAMP(String geneName, String userName,
			String stepType, Float ml, Float volume, Float excess, Date recordDate, 
			String stored, String position, String comments) {
		// TODO Auto-generated method stub
		
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		
		GeneAmplification amp = new GeneAmplification();
		amp.setComments(comments);
		amp.setDateModified(new Date());
		amp.setExcess(excess);
		amp.setMl(ml);
		amp.setPosition(position);
		amp.setRecordDate(recordDate);
		amp.setStepType(stepType);
		amp.setStored(stored);
		amp.setUser(u);
		amp.setGene(g);
		amp.setVolume(volume);
		
		GeneAmplificationDAO dao = new GeneAmplificationDAO();
		dao.addGeneAmplification(amp);
		
	}

	@Override
	public GeneAmplification getGeneAMP(String geneName, 
			String stepType) {
		// TODO Auto-generated method stub
		
		GeneAmplification geneAMP = null;
		GeneAmplificationDAO dao = new GeneAmplificationDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		geneAMP = dao.getGeneAmplification(gene, stepType);
		return geneAMP;
		
	}

	@Override
	public List<GeneAmplification> getGeneAmplificationHistory(String geneName,
			 String stepType) {
		// TODO Auto-generated method stub
		
		List<GeneAmplification> g = null;
		GeneAmplificationDAO dao = new GeneAmplificationDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		g = dao.getGeneAmplificationHistory(gene, stepType);
		return g;
	}

}
